package com.zhentao.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhentao.nlz.project.dto.DetectionProcessDto;
import com.zhentao.nlz.project.dto.TDeptDto;
import com.zhentao.nlz.project.product.TDetectionProcess;
import com.zhentao.product.mapper.TDetectionProcessMapper;
import com.zhentao.product.service.TDetectionProcessService;
import com.zhentao.utils.Result;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author 不.凌
* @description 针对表【t_detection_process】的数据库操作Service实现
* @createDate 2024-09-22 21:09:18
*/
@Service
public class TDetectionProcessServiceImpl extends ServiceImpl<TDetectionProcessMapper, TDetectionProcess>
    implements TDetectionProcessService{

    @Override
    public Result DetectionProcessList(DetectionProcessDto detectionProcessDto) {
        Page<TDetectionProcess> page = new Page<>(detectionProcessDto.getPageNum(), detectionProcessDto.getPageSize());
        LambdaQueryWrapper<TDetectionProcess> wrapper=new LambdaQueryWrapper<>();
        wrapper.like(StringUtils.isNotBlank(detectionProcessDto.getPlateId()),TDetectionProcess::getPlateId,detectionProcessDto.getPlateId())
                .eq(StringUtils.isNotBlank(detectionProcessDto.getStatus()),TDetectionProcess::getStatus,detectionProcessDto.getStatus())
                .like(StringUtils.isNotBlank(detectionProcessDto.getContent()),TDetectionProcess::getContent,detectionProcessDto.getContent())
                .like(StringUtils.isNotBlank(detectionProcessDto.getResultNote()),TDetectionProcess::getResultNote,detectionProcessDto.getResultNote());
        this.page(page,wrapper);
        return Result.success(page);
    }

    @Override
    public Result DetectionProcessAdd(TDetectionProcess detectionProcess) {
        detectionProcess.setStartTime(new Date());
        detectionProcess.setEndTime(new Date());
        boolean save = this.save(detectionProcess);
        return Result.success("添加成功",save);
    }

    @Override
    public Result DetectionProcessUpdate(TDetectionProcess detectionProcess) {
        detectionProcess.setUpdateTime(new Date());
        boolean update = this.updateById(detectionProcess);
        return Result.success("修改成功",update);
    }

    @Override
    public Result DetectionProcessDelete(Integer id) {
        boolean remove = this.removeById(id);
        return Result.success("删除成功",remove);
    }
}




